#ifndef WIDGET_ENCODER_H
#define WIDGET_ENCODER_H
#include <optional>
#include <string>
#include "widget_codec_global.h"
namespace dymy {
enum class WidgetType { Text, Container };

class WIDGET_CODEC_EXPORT  Widget {
public:
  WidgetType type;
  virtual std::string generateCode() const = 0;
};

class WIDGET_CODEC_EXPORT Text : public Widget {
public:
  std::string text;
  std::optional<std::string> font_family;
  std::optional<int> font_weight;
  std::optional<float> font_size;
  std::optional<float> line_height;
  std::optional<int> color;
  std::optional<float> letter_space;

  std::string generateCode() const override;
  std::string generateTextStyle() const;

private:
  void writeTextStyle(std::stringstream &ss,const char *table)const;
};

class WIDGET_CODEC_EXPORT EdgeInsets {
public:
  constexpr EdgeInsets(float left, float top, float right, float bottom)
      : left(left), top(top), right(right), bottom(bottom) {}
  constexpr EdgeInsets(float horizontal, float vertical)
      : EdgeInsets(horizontal, vertical, horizontal, horizontal) {}
  float left;
  float top;
  float right;
  float bottom;
};
class WIDGET_CODEC_EXPORT Container : public Widget {

public:
  struct Border {
    float border_width;
    int border_color;
  };

  std::optional<EdgeInsets> padding;
  std::optional<Border> border;
  std::optional<int> background;
  std::optional<float> border_radius;

  std::string generateCode() const override;
};

} // namespace dymy

#endif // WIDGET_ENCODER_H
